# -*- autoconf -*-
#########################################
##
# Checks for libraries that are run
# after the agent module tests.
##
#########################################

#   HAVE_LIB Definitions used in the Net-SNMP code base:
#
#       HAVE_LIBCRYPTO:	apps
#       HAVE_LIBRPM:	agent
#

##
#   Simple checks:
##

#   ELF libraries
#       Typically used for 'nlist'  (needed for uptime)
#
if test "x$with_elf" != "xno"; then
case $target_os in
	linux*) # add hosts which don't use nlist here
                ;;
	irix*) # Check for nlist in mld (irix)
		AC_CHECK_LIB(elf, nlist)
		AC_CHECK_LIB(elf, nlist64)
		AC_CHECK_LIB(mld, nlist)
		;;
	*) # default
		AC_CHECK_LIB(elf, nlist)
		;;
esac
fi
 

#   libsocket
#       Needed for 'socket(2)'                          (Solaris)
#       Possibly also for 'gethostname(3)'              (non-Solaris)
#           (alternatively in libnsl                    (Solaris)
#            or in libws2_32)                           (MinGW)
#
case x$with_socklib in
xwinsock2)
  #   libws2_w32                                        (MinGW)
  #
  netsnmp_save_LIBS="$LIBS"
  LIBS="$LIBS -lws2_32"
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
    #include <winsock2.h>
  ], [
    socket(0, 0, 0);
    gethostbyname(0);
  ])], [
    # Keep LIBS.
    true
  ], [
    # Restore LIBS and complain.
    LIBS="$netsnmp_save_LIBS"
    AC_MSG_ERROR([libws2_32 not found.])
  ])
  ;;
*)
  AC_SEARCH_LIBS(socket, socket,,AC_MSG_ERROR([socket(2) not found.]))
  AC_SEARCH_LIBS(gethostbyname, [nsl socket])
  AC_CHECK_FUNCS(gethostbyname)
  AC_SEARCH_LIBS(gethostbyaddr, [nsl socket])
  AC_CHECK_FUNCS(gethostbyaddr)
  ;;
esac


#   libiphlpapi                                         (Cygwin and MinGW)
#
netsnmp_save_LIBS="$LIBS"
LIBS="$LIBS -liphlpapi"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include <winsock2.h>
  #include <iphlpapi.h>
], [
  IpRenewAddress(0);
])], [
  # Keep LIBS.
  true
], [
  # Restore LIBS and complain.
  LIBS="$netsnmp_save_LIBS"
  case x$with_socklib in
  xwinsock2)
    AC_MSG_ERROR([libiphlpapi not found.])
    ;;
  esac
])

AC_MSG_CHECKING([for MIB_IF_TABLE2])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #define _WIN32_WINNT 0xffff
  #include <winsock2.h>
  #include <ws2tcpip.h>
  #include <iphlpapi.h>
],[
  return sizeof(MIB_IF_TABLE2)
])],[
  AC_MSG_RESULT([yes])
  AC_DEFINE([HAVE_MIB_IF_TABLE2], 1,
    [Define if MIB_IF_TABLE2 is available])],
  [AC_MSG_RESULT([no])])


#   libregex                                            (MinGW)
#
netsnmp_save_LIBS="$LIBS"
LIBS="$LIBS -lregex"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include <sys/types.h>
  #include <regex.h>
], [
  regcomp(0, 0, 0);
])], [
  # Keep LIBS.
  true
], [
  # Restore LIBS.
  LIBS="$netsnmp_save_LIBS"
])


#   libsnmpapi                                          (MinGW)
#
netsnmp_save_LIBS="$LIBS"
LIBS="$LIBS -lsnmpapi"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include <snmp.h>
], [
  SnmpUtilMemAlloc(0);
])], [
  # Keep LIBS.
  true
], [
  # Restore LIBS.
  LIBS="$netsnmp_save_LIBS"
])


#   kstat library                                       (Solaris)
#
AC_CHECK_LIB(kstat, kstat_lookup, [LNETSNMPLIBS="$LNETSNMPLIBS -lkstat"])


#   socket library                                      (Solaris)
#
AC_CHECK_LIB(socket, in6addr_any, [LNETSNMPLIBS="$LNETSNMPLIBS -lsocket"])


#
#   librt
#

NETSNMP_SEARCH_LIBS(clock_gettime, rt,
        AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
                [Define to 1 if you have the `clock_gettime' library]),,,
        LNETSNMPLIBS)


##
#   MIB-module-specific checks
##

#   libdevstat
#        (for diskIO MIB)
#
#   Not-Used: HAVE_GETDEVS/HAVE_DEVSTAT_GETDEVS
#
echo " $module_list " | $GREP " ucd-snmp/diskio " >/dev/null
if test $? -eq 0 ; then
	NETSNMP_SEARCH_LIBS(getdevs, devstat,
                AC_DEFINE(HAVE_GETDEVS, 1,
                        [define if you have getdevs()]),,,LMIBLIBS)
	NETSNMP_SEARCH_LIBS(devstat_getdevs, devstat,
                AC_DEFINE(HAVE_DEVSTAT_GETDEVS, 1,
                        [define if you have devstat_getdevs()]),,,LMIBLIBS)
fi

#   libpci
#        (for if-mib description)
#
NETSNMP_SEARCH_LIBS(pci_lookup_name, pci,
	AC_DEFINE(HAVE_PCI_LOOKUP_NAME, 1,
		[define if you have pci_lookup_name()]),,,LMIBLIBS)

#   LM-SENSORS-MIB support
#
echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
if test $? -eq 0 ; then
        AC_MSG_CHECKING([for sensors support])
        case $target_os in
        solaris*)
            #  Agent:  HAVE_PICL_H
            #
            AC_CHECK_HEADER(picl.h, LMIBLIBS="${LMIBLIBS} -lpicl",)
            AC_CHECK_HEADERS(picl.h)
            ;;
        *)
            #  Not-Used:  HAVE_SENSORS_SENSORS_H
            #
            AC_CHECK_HEADER(sensors/sensors.h,,
                [AC_MSG_ERROR([asked to use lm_sensors but I couldn't find sensors/sensors.h])])
            NETSNMP_SEARCH_LIBS(sensors_get_detected_chips, sensors,,
                [AC_MSG_ERROR([asked to use lm_sensors but I couldn't find -lsensors])],,
                LMIBLIBS)
            ;;
        esac
fi

#
# libnl (netlink)
#

if test "x$with_nl" != "xno"; then
    case $target_os in
    linux*) # Check for libnl (linux)
        # The test below verifies whether the libnl-3 package been installed.
        # This test works as follows:
        # - If pkg-config was not installed at the time autogen.sh was run,
        #   the definition of the PKG_CHECK_EXISTS() macro will not be found by
        #   autogen.sh. Augogen.sh will generate a configure script that prints
        #   a warning about pkg-config and proceeds as if libnl-3 has not been
        #   installed.
        # - If pkg-config was installed at the time autogen.sh was run,
        #   the generated configure script will try to detect the presence of
        #   the libnl-3 library by looking up compile and linker flags in the
        #   file called libnl-3.pc.
        # - pkg-config settings can be overridden via the configure variables
        #   LIBNL3_CFLAGS and LIBNL3_LIBS (added by the pkg-config m4 macro's to
        #   the configure script -- see also ./configure --help).
        # - The LIBNL3_CFLAGS and LIBNL3_LIBS configure variables can be used
        #   even if the pkg-config executable is not present on the system on
        #   which the configure script is run.
        ifdef(
          [PKG_CHECK_EXISTS],
          [PKG_CHECK_EXISTS([libnl-3.0],
            [PKG_CHECK_MODULES([LIBNL3], [libnl-3.0])])
          ],
          AC_MSG_WARN([pkg-config has not been installed or is too old.])
          AC_MSG_WARN([Detection of libnl-3.0 will be skipped.])
        )

        netsnmp_save_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="${LIBNL3_CFLAGS} $CPPFLAGS"
        NETSNMP_SEARCH_LIBS(nl_connect, nl-3,
            [AC_CHECK_HEADERS(netlink/netlink.h)
            EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES ${LIBNL3_CFLAGS}"],
            [CPPFLAGS="$netsnmp_save_CPPFLAGS"], [], [LMIBLIBS])
        if test "x$ac_cv_header_netlink_netlink_h" != xyes; then
            NETSNMP_SEARCH_LIBS(nl_connect, nl, [
                AC_CHECK_HEADERS(netlink/netlink.h)], [], [], LMIBLIBS)
        fi
        if test "x$ac_cv_header_netlink_netlink_h" = xyes; then
            AC_EGREP_HEADER([nl_socket_free], [netlink/socket.h],
                            [AC_DEFINE([HAVE_LIBNL3], [1],
                            [Define to 1 if <netlink/netlink.h> provides the
                            libnl3 API])])
        fi
    ;;
    esac
fi



##
#   More complex checks:
##

#   Security related functions
#
NONAGENTLIBS=$LIBS	 # save old libraries
SSHPROG=no
TLSPROG=no
if test "x$tryopenssl" != "xno" -a "x$tryopenssl" != "xinternal"; then
    # check for libpkcs11 if asked
    if test "x$askedopenssl" != "xyes" -a "x$askedpkcs" = "xyes"; then
        AC_CHECK_LIB(pkcs11, C_Initialize,
            AC_DEFINE(HAVE_LIBPKCS11, 1,
                [Define to 1 if you have the `pkcs11' library (-lpkcs11).])
		LIBPKCS11="-lpkcs11")
    else 
        if test "x$tryrsaref" != "xno"; then
            AC_CHECK_LIB(rsaref, RSAPrivateDecrypt)
            AC_CHECK_LIB(RSAglue, RSA_PKCS1_RSAref)
        fi

        AC_MSG_CHECKING([for -leay32])
        netsnmp_save_LIBS="$LIBS"
        LIBS="-leay32"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([
                #include <openssl/evp.h>],
                [return EVP_md5();])],
            [AC_MSG_RESULT(yes); ac_cv_lib_eay32_EVP_md5=yes; CRYPTO="eay32"],
            [AC_MSG_RESULT(no)]
        )
        LIBS="$netsnmp_save_LIBS"

        if test x$CRYPTO = x; then
            AC_CHECK_LIB([crypto], [EVP_md5],
			 [CRYPTO="crypto"; LIBCRYPTO="-lcrypto"], [
		unset ac_cv_lib_crypto_EVP_md5
		AC_CHECK_LIB([crypto], [EVP_md5],
			     [CRYPTO="crypto"; LIBCRYPTO="-lcrypto -lz"], [],
			     [-lz])
	    ])
	else
	    LIBCRYPTO="-l${CRYPTO}"
	fi

        if test x$CRYPTO != x; then
            AC_DEFINE(HAVE_LIBCRYPTO, 1,
                [Define to 1 if you have the OpenSSL library (-lcrypto or -leay32).])
            netsnmp_save_LIBS="$LIBS"
            LIBS="$LIBCRYPTO"
            AC_CHECK_FUNCS([AES_cfb128_encrypt]dnl
                           [EVP_sha224        EVP_sha384        ]dnl
                           [EVP_MD_CTX_create EVP_MD_CTX_destroy]dnl
                           [EVP_MD_CTX_new    EVP_MD_CTX_free   ]dnl
                           [DH_set0_pqg DH_get0_pqg DH_get0_key]dnl
                           [ASN1_STRING_get0_data X509_NAME_ENTRY_get_object]dnl
                           [X509_NAME_ENTRY_get_data X509_get_signature_nid])
            AC_MSG_CHECKING([whether 2nd app_verify_cookie_cb() arg is const])
            netsnmp_save_CFLAGS="$CFLAGS"
            CFLAGS="$CFLAGS -Werror"
            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
              #include <openssl/ssl.h>
            ]],[[
              int (*app_verify_cookie_cb)(SSL *ssl,
                                          const unsigned char *cookie,
                                          unsigned int cookie_len) = NULL;
              SSL_CTX_set_cookie_verify_cb(NULL, app_verify_cookie_cb);
            ]])],
            [AC_MSG_RESULT(yes); ac_cv_saccaq=const],
            [AC_MSG_RESULT(no)])
            AC_DEFINE_UNQUOTED([SECOND_APPVERIFY_COOKIE_CB_ARG_QUALIFIER],
                               [$ac_cv_saccaq],
                               [Qualifier for second argument of the appverify_cookie_cb() callback function])
            CFLAGS="$netsnmp_save_CFLAGS"
            LIBS="$netsnmp_save_LIBS"
        fi
        netsnmp_save_LIBS="$LIBS"
        LIBS="-lssl $LIBCRYPTO"
        AC_CHECK_FUNCS([TLS_method TLSv1_method DTLS_method DTLSv1_method]dnl
                       [SSL_library_init SSL_load_error_strings]dnl
		       [ERR_get_error_all])
        LIBS="$netsnmp_save_LIBS"
        if echo " $transport_result_list " | $GREP "DTLS" > /dev/null; then
	    if test x$ac_cv_func_DTLSv1_method = xyes -o \
                    x$ac_cv_func_DTLS_method = xyes; then
                AC_DEFINE(HAVE_LIBSSL_DTLS, 1,
                    [Define to 1 if your `ssl' library supports DTLS (-lssl).])
                LIBCRYPTO=" -lssl $LIBCRYPTO"
	    else
		AC_MSG_ERROR([The DTLS based transports require the libssl library from OpenSSL to be available and support DTLS])
            fi
            TLSPROG=yes
        fi
        if echo " $transport_result_list " | $GREP "TLS" > /dev/null; then
	    if test x$ac_cv_func_TLSv1_method = xyes -o \
                    x$ac_cv_func_TLS_method = xyes; then
                AC_DEFINE(HAVE_LIBSSL, 1,
                    [Define to 1 if you have the `ssl' library (-lssl).])
                LIBCRYPTO=" -lssl $LIBCRYPTO"
            else
		AC_MSG_ERROR([The TLS based transports require the libssl library from OpenSSL to be available])
            fi
            TLSPROG=yes
        fi
        if echo " $transport_result_list " | $GREP " SSH " > /dev/null; then
	    AC_CHECK_LIB(ssh2, libssh2_session_startup,
                AC_DEFINE(HAVE_LIBSSH2, 1,
                    [Define to 1 if you have the `ssh2' library (-lssh2).])
                LIBCRYPTO=" -lssh2 $LIBCRYPTO",
                AC_MSG_ERROR([The SSH transport requires the libssh2 library to be available]),)
            SSHPROG=yes
        fi
    fi
elif test "x$askedpkcs" = "xyes"; then
    AC_CHECK_LIB(pkcs11, C_Initialize,
        AC_DEFINE(HAVE_LIBPKCS11)
        LIBPKCS11="-lpkcs11")
fi

LIBS=$NONAGENTLIBS	 # restore old libraries
if test "x$SSHPROG" = "xyes"; then
    NETSNMP_BUILD_SSH_PROG_TRUE=''
    NETSNMP_BUILD_SSH_PROG_FALSE='#'
else
    NETSNMP_BUILD_SSH_PROG_TRUE='#'
    NETSNMP_BUILD_SSH_PROG_FALSE=''
fi
if test "x$TLSPROG" = "xyes" -a "x$enable_read_only" != "xyes" ; then
    NETSNMP_BUILD_TLS_PROG_TRUE=''
    NETSNMP_BUILD_TLS_PROG_FALSE='#'
else
    NETSNMP_BUILD_TLS_PROG_TRUE='#'
    NETSNMP_BUILD_TLS_PROG_FALSE=''
fi
if echo " ${security_mod_list} " | grep ' usm ' ; then
    if test "x$enable_read_only" != "xyes" ; then
    	NETSNMP_BUILD_USM_PROG_TRUE=''
    	NETSNMP_BUILD_USM_PROG_FALSE='#'
    else
    	NETSNMP_BUILD_USM_PROG_TRUE='#'
    	NETSNMP_BUILD_USM_PROG_FALSE=''
    fi
else
    NETSNMP_BUILD_USM_PROG_TRUE='#'
    NETSNMP_BUILD_USM_PROG_FALSE=''
fi
if test "x$enable_read_only" != "xyes" ; then
    NETSNMP_BUILD_SET_PROG_TRUE=""
    NETSNMP_BUILD_SET_PROG_FALSE="#"
else
    NETSNMP_BUILD_SET_PROG_TRUE="#"
    NETSNMP_BUILD_SET_PROG_FALSE=""
fi
AC_SUBST(NETSNMP_BUILD_SSH_PROG_TRUE)
AC_SUBST(NETSNMP_BUILD_SSH_PROG_FALSE)
AC_SUBST(NETSNMP_BUILD_TLS_PROG_TRUE)
AC_SUBST(NETSNMP_BUILD_TLS_PROG_FALSE)
AC_SUBST(NETSNMP_BUILD_USM_PROG_TRUE)
AC_SUBST(NETSNMP_BUILD_USM_PROG_FALSE)
AC_SUBST(NETSNMP_BUILD_SET_PROG_TRUE)
AC_SUBST(NETSNMP_BUILD_SET_PROG_FALSE)

#
# If we're using internal crypto support we need to compile in extra files
#
crypto_files_c=""
crypto_files_o=""
crypto_files_lo=""
if test "x$tryopenssl" != "xno" -a "x$CRYPTO" = "x"; then
   # If we:
   #   1) couldn't find needed openssl support
   #   2) OR were asked to use internal support
   #   3) AND we have the needed files
   # then use it
   CRYPTO="internal"
   crypto_files_c="openssl/openssl_sha1.c openssl/openssl_md5.c openssl/openssl_set_key.c openssl/openssl_des_enc.c openssl/openssl_cbc_enc.c openssl/openssl_aes_cfb.c openssl/openssl_aes_core.c openssl/openssl_cfb128.c"
   crypto_files_o="openssl/openssl_sha1.o openssl/openssl_md5.o openssl/openssl_set_key.o openssl/openssl_des_enc.o openssl/openssl_cbc_enc.o openssl/openssl_aes_cfb.o openssl/openssl_aes_core.oo openssl/openssl_cfb128.o"
   crypto_files_lo="openssl/openssl_sha1.lo openssl/openssl_md5.lo openssl/openssl_set_key.lo openssl/openssl_des_enc.lo openssl/openssl_cbc_enc.lo openssl/openssl_aes_cfb.lo openssl/openssl_aes_core.lo openssl/openssl_cfb128.lo"
   AC_DEFINE(HAVE_AES_CFB128_ENCRYPT)
fi
AC_SUBST(crypto_files_c)
AC_SUBST(crypto_files_o)
AC_SUBST(crypto_files_lo)

#
# if we can do any sort of crypto then note it
#
if test "x$CRYPTO" != "x" ; then
  AC_DEFINE(NETSNMP_CAN_DO_CRYPTO, 1, "Define if crytography support is possible")
fi

#   TCP wrapper support
#
_cppflags="${CPPFLAGS}"
_ldflags="${LDFLAGS}"
if test "$with_libwrap" != "no"; then
  if test "$with_libwrap" != "yes"; then
    CPPFLAGS="${CPPFLAGS} -I$with_libwrap/include"
    LDFLAGS="${LDFLAGS} -L$with_libwrap/lib"
  fi

  _libs=${LIBS}
  AC_CHECK_HEADER(tcpd.h, ,
    AC_MSG_ERROR([Asked to use libwrap but I couldn't find tcpd.h.]))

  LIBS="$LIBS -lwrap"
  AC_MSG_CHECKING([for TCP wrappers library -lwrap])
  # XXX: should check for hosts_ctl
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
     #include <tcpd.h>
     int allow_severity = 0;
     int deny_severity  = 0;]],
    [[hosts_access((void *)0)]])],
    [AC_MSG_RESULT([yes])
     AC_DEFINE(NETSNMP_USE_LIBWRAP)
     test "$with_libwrap" != no -a "$with_libwrap" != yes && _wraplibs="-L$with_libwrap/lib"
     _wraplibs="$_wraplibs -lwrap"],
    [AC_MSG_RESULT([no])
     # Linux RedHat 6.1 won't link libwrap without libnsl
     AC_CHECK_FUNC(yp_get_default_domain, ,
       AC_CHECK_LIB(nsl, yp_get_default_domain))
     AC_MSG_CHECKING([for TCP wrappers library -lwrap linked with -lnsl])
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
	#include <tcpd.h>
	int allow_severity = 0;
	int deny_severity  = 0;]],
       [[hosts_access((void *)0)]])],
       [AC_MSG_RESULT(yes)
	AC_DEFINE(NETSNMP_USE_LIBWRAP)
	test "$with_libwrap" != no -a "$with_libwrap" != yes && _wraplibs="-L$with_libwrap/lib"
	_wraplibs="$_wraplibs -lwrap -lnsl"],
       [AC_MSG_RESULT(no)
	AC_MSG_ERROR(Asked to use libwrap but I couldn't find it.)])])
  LAGENTLIBS="$_wraplibs"
  CPPFLAGS=${_cppflags}
  LDFLAGS=${_ldflags}
  LIBS=${_libs}
fi


##
#   mysql
##
if test "x$with_mysql" = "xyes" ; then
  AC_PATH_PROGS(MYSQLCONFIG,mysql_config)
  test -x "$MYSQLCONFIG" \
	|| AC_MSG_ERROR([Could not find mysql_config and was specifically asked to use MySQL support])
  MYSQL_LIBS=`$MYSQLCONFIG --libs`
  MYSQL_INCLUDES=`$MYSQLCONFIG --include`
  _libs="${LIBS}"
  _cppflags="${CPPFLAGS}"
  LIBS="${LIBS} ${MYSQL_LIBS}"
  CPPFLAGS="${CPPFLAGS} ${MYSQL_INCLUDES}"
  AC_CHECK_HEADER(mysql.h,,
     [AC_MSG_ERROR([Could not find mysql.h and was specifically asked to use MySQL support])])
  AC_CHECK_HEADERS([my_global.h my_sys.h])
  AC_MSG_CHECKING([whether MY_INIT() works])
  AC_LINK_IFELSE([
    AC_LANG_PROGRAM(
      [[#ifdef HAVE_MY_GLOBAL_H
        #include <my_global.h>
        #endif
        #ifdef HAVE_MY_SYS_H
        #include <my_sys.h>
        #endif
        #include <mysql.h>]],
      [[MY_INIT("my_init_test")]])],
      [AC_MSG_RESULT(yes)
       AC_DEFINE([HAVE_MY_INIT], 1,
                 [Define if MY_INIT() is availabe in libmysqlclient])],
      [AC_MSG_RESULT(no)])
  AC_MSG_CHECKING([whether my_load_defaults() exists])
  AC_LINK_IFELSE([
    AC_LANG_PROGRAM(
      [[#ifdef HAVE_MY_GLOBAL_H
        #include <my_global.h>
        #endif
        #ifdef HAVE_MY_SYS_H
        #include <my_sys.h>
        #endif
        #include <mysql.h>]],
      [[my_load_defaults("my_init_test")]])],
      [AC_MSG_RESULT(yes)
       AC_DEFINE([HAVE_MY_LOAD_DEFAULTS], 1,
                 [Define if having my_load_defaults()])],
      [AC_MSG_RESULT(no)])
  AC_CHECK_FUNCS([load_defaults mysql_init mysql_options])
  CPPFLAGS="${_cppflags}"
  LIBS="${_libs}"
  AC_MSG_CACHE_ADD(MYSQL Trap Logging:         enabled)
else
  AC_MSG_CACHE_ADD(MYSQL Trap Logging:         unavailable)
fi
AC_SUBST(MYSQL_LIBS)
AC_SUBST(MYSQL_INCLUDES)

##
#   libpcap
##
NETSNMP_BUILD_PCAP_PROG_TRUE='#'
NETSNMP_BUILD_PCAP_PROG_FALSE=''
AC_CHECK_LIB([pcap], [pcap_create], [
   AC_CHECK_HEADERS([pcap/pcap.h], [
      NETSNMP_BUILD_PCAP_PROG_TRUE=''
      NETSNMP_BUILD_PCAP_PROG_FALSE='#'
       ])
])
AC_SUBST(NETSNMP_BUILD_PCAP_PROG_TRUE)
AC_SUBST(NETSNMP_BUILD_PCAP_PROG_FALSE)

##
#   Non-library checks
##

# nlist
AC_CHECK_FUNCS(nlist nlist64 knlist)

NETSNMP_SEARCH_LIBS([endwin], [curses ncurses], [
  AC_CHECK_HEADERS([curses.h])
  AC_CHECK_HEADERS([ncurses/curses.h])
  HAVE_LIBCURSES=TRUE],
  [HAVE_LIBCURSES=FALSE],,
  [LIBCURSES])
AC_SUBST([HAVE_LIBCURSES])
AC_SUBST([LIBCURSES])

#   libm for ceil
#
NETSNMP_SEARCH_LIBS(ceil, m,,,, LNETSNMPLIBS)
